// 找每个元素的所在区间

#include <bits/stdc++.h>
using namespace std;
using ll = long long;

const int N = 1e5 + 10;
ll dp[2][205];
int n, k;
int a[N], p[205];
int main()
{
  ios::sync_with_stdio(0), cin.tie(0);
  cin >> n >> k;
  for (int i = 1; i <= n; i++)
    cin >> a[i];
  for (int i = 1; i <= k; i++)
    cin >> p[i];
  memset(dp, -0x3f, sizeof(dp));
  dp[0][0] = 0;
  int now = 0, pre = 1;
  for (int i = 1; i <= n; i++)
  {
    // 转移为新层
    swap(now, pre);
    // 覆盖脏数据
    memset(dp[now], -0x3f, sizeof(dp[now]));
    for (int j = 1; j <= k; j++)
    {
      // dp[pre][j], dp[pre][j - 1]分别代表新建区间,插入旧区间
      // + 1ll * a[i] * p[j]代表将a[i]划入j区间
      dp[now][j] = max(dp[pre][j], dp[pre][j - 1]) + 1ll * a[i] * p[j];
    }
  }
  cout << dp[now][k];
  return 0;
}
